package com.fr.chicken.controller;

import com.fr.chicken.annotation.Verification;
import com.fr.chicken.facade.base.BaseResponseDTO;
import com.fr.chicken.service.UploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;

@RestController
@RequestMapping(value="/upload")
@Api(value = "/api-upload", description = "文件管理")
public class UploadController {
    @Resource
    private UploadService uploadService;

    @Verification
    @ApiOperation(value = "上传图片", response = BaseResponseDTO.class, notes = "上传图片")
    @RequestMapping(value = "/uploadImg", method = RequestMethod.POST, produces = "application/json")
    public BaseResponseDTO uploadImg(@RequestHeader String accessToken,
                                     @PathVariable(value = "multipartFile") @ApiParam(required = true, value = "图片") MultipartFile multipartFile) {
        BaseResponseDTO responseDTO = uploadService.uploadImg(multipartFile);
        return responseDTO;
    }
}
